﻿using Prism.Events;
using Prism.Mvvm;
using RoboAssembleX.Application.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RoboAssembleX.ViewModels
{
    public class ViewMessageShowViewModel : BindableBase
    {
        private readonly IEventAggregator eventAggregator;
        public ObservableCollection<MessageEventArgs> Messages { get; set; } = new ObservableCollection<MessageEventArgs>();
        public ViewMessageShowViewModel(IEventAggregator eventAggregator)
        {
            eventAggregator.GetEvent<MessageEvent>().Subscribe(ReceiveMessageEvent,ThreadOption.UIThread);
        }

        private void ReceiveMessageEvent(MessageEventArgs msg)
        {
            Messages.Add(msg);
        }
    }
}
